<!DOCTYPE html>
<html>
<head>
  <title>Parallel events in story element</title>
  <meta charset="utf-8" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />

  <style>
    html,body {
      text-align: center;
      margin: 0; padding: 0;
      font-family: Georgia;
      background: #EEE;
      height: 100%;
    }
    #map { width: 100%; height: 100%; }    
  </style>
</head>
<body>
 <div id="map"> </div>

  <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  <script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
  <script src="../../dist/odyssey.js" charset="UTF-8"></script>
  <script>


  var defaultIcon = L.icon({
      iconUrl: '../icons/circle-stroked-24.png'
  });

  // define some places to visit
  var spain = new L.LatLng(40.9218144123785, -3.69140625);
  var brazil = new L.LatLng(-9.871451997300536, -52.5585937);
  var usa = new L.LatLng(38.487994609214795,  -98.96484375);

  // create a map
  var map = new L.Map('map', {
    zoomControl: false,
    center: [37, -91],
    zoom: 6
  });

  L.tileLayer('http://{s}.tile.stamen.com/toner/{z}/{x}/{y}.jpg', { attribution: 'data OSM - map stamen' }).addTo(map).setOpacity(0.9);

  // create a sequential trigger
  var seq = O.Sequential();

  // when press left mode to next
  O.Keys().left().then(seq.prev, seq)
  O.Keys().right().then(seq.next, seq)

  // create a story 
  var story = O.Story()
      .addState(
        seq.step(0),
        // Parallel executes a list of commands in one action
        O.Parallel(
          map.actions.panTo(spain, {animate: false}),
          map.actions.setZoom(7)
        )
      )
      .addState(
        seq.step(1),
        O.Parallel(
          map.actions.panTo(brazil, {animate: false}),
          map.actions.setZoom(5)
        )
      )
      .addState(
        seq.step(2),
        O.Parallel(
          map.actions.panTo(usa, {animate: false}),
          map.actions.setZoom(4)
        )
      )

  // Start the story, go to step(0)
  story.go(0);
                       

  </script>
</body>
</html>

